import {
    TSPointDto,
    TSPointQueryConditionDto,
    TSNumDataQueryConditionDto,
    TSNumDataDto,
    TSPointListModel,
    TSNumDataListModel,
    TSNumDataFixedQueryConditionDto, TSNumDataQueryResultDto
} from './model/timeSeriesModel';

import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';

enum Api {
  PointsQuery = '/demo/tspoint/query',
  PointsAdd = '/demo/tspoint/add',
  PointsUpdate = '/demo/tspoint/update',
  PointsDelete = '/demo/tspoint/delete',
  PointsGet = '/demo/tspoint/get',
  DataQuery = '/demo/tsnumdata/query',
  DataSave = '/demo/tsnumdata/save',
  DataAdd = '/demo/tsnumdata/add',
  DataUpdate = '/demo/tsnumdata/update',
  DataDelete = '/demo/tsnumdata/delete',
  PointsQueryFixed = '/demo/tsnumdata/queryfixed',

}

/**
 * @description: 时序数据点号查询
 */
export function queryPoints(params: TSPointQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<TSPointListModel>(
    {
      url: Api.PointsQuery,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description 获取指定点号信息，多个点号ID使用逗号分隔
 */
export function getPoints(id: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<TSPointListModel>(
    {
      url: Api.PointsGet,
      params: { id: id },
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 时序数据点号修改
 * @param params
 * @param mode
 */
export function updatePoints(params: TSPointDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<string>(
    {
      url: Api.PointsUpdate,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
 * 时序数据点号新增
 */
export function addPoints(params: TSPointDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<string>(
    {
      url: Api.PointsAdd,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
* 时序数据点号删除
* */
export function deletePoints(id: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete<string>(
    {
      url: `${Api.PointsDelete}?id=${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 时序数据点号数值数据查询
 */
export async function queryPointNumberDatas(params: TSNumDataQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<TSNumDataQueryResultDto>(
    {
      url: Api.DataQuery,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
 * 时序数据点号数值数据保存
 */
export function savePointNumberDatas(params: TSNumDataListModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<string>(
    {
      url: Api.DataSave,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
 * 时序数据点号数值数据新增-单条新增
 */
export function addPointNumberData(params: TSNumDataDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<string>(
    {
      url: Api.DataAdd,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
 * 时序数据点号数值数据修改-单条修改
 */
export function updatePointNumberData(params: TSNumDataDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<string>(
    {
      url: Api.DataUpdate,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/*
 * 时序数据点号数值数据删除
 */
export function deletePointNumberDatas(params: TSNumDataListModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete<string>(
    {
      url: Api.DataDelete,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 查询指定时间点的点好数据值 queryFixed
 */
export function queryfixedPointNumberDatas(params: TSNumDataFixedQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<TSNumDataQueryResultDto>(
    {
      url: Api.PointsQueryFixed,
      data: params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

